﻿<UserControl x:Class="InfFront.InfoViews.WPF.ExplorerFrame"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:InfFront.InfoViews.WPF"
    xmlns:viewbase="clr-namespace:InfFront.InfoViews.Base;assembly=InfFront.InfoViews.Base"
    xmlns:system="clr-namespace:System;assembly=mscorlib"
    Height="Auto" Width="Auto">
        
    <UserControl.Resources>
        <local:IconedObjectToNormal24x24ImageConverter x:Key="getNormal24x24Image"/>
        <local:InfoViewSourceSelectionCheckConverter x:Key="getIsViewSourceSelected"/>
        <local:BoolNotConverter x:Key="BoolNot" />
    </UserControl.Resources>
    
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="200" Width="{Binding Path=VisualSettings.SourceListPanelWidth, FallbackValue=200, Mode=TwoWay}" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition MinWidth="300"/>
        </Grid.ColumnDefinitions>
        
        <Grid Grid.Column="0">
            <Grid.Background>
                <SolidColorBrush Color="{Binding Path=VisualSettings.PrimaryBackgroundColor, FallbackValue=Lavender}" />
            </Grid.Background>
            <TreeView Name="tvSources" BorderThickness="0" Width="Auto"
                      SelectedItemChanged="tvSources_SelectedItemChanged"
                      Background="Transparent">
                <TreeView.ItemContainerStyle>
                    <Style TargetType="{x:Type TreeViewItem}">
                        <Setter Property="IsExpanded" Value="True" />
                        <Setter Property="IsSelected" Value="{Binding Converter={StaticResource getIsViewSourceSelected}, Mode=OneWay}" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=IsDummy}" Value="True">
                                <Setter Property="FontStyle" Value="Italic" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path=IsDummy}" Value="False">
                                <Setter Property="FontStyle" Value="Normal" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TreeView.ItemContainerStyle>
                <TreeView.ItemTemplate>
                    <HierarchicalDataTemplate DataType = "{x:Type viewbase:InfoViewSource}"
                                              ItemsSource = "{Binding Path=NestedSources}">
                        <WrapPanel Margin="4">
                            <Image Source="{Binding Converter={StaticResource getNormal24x24Image}}" Width="24" />
                            <TextBlock Name="InfoSourceTextBlock" Margin="4" FontWeight="Bold" Text="{Binding Path=Title}" VerticalAlignment="Center" />
                        </WrapPanel>
                    </HierarchicalDataTemplate>
                </TreeView.ItemTemplate>
            </TreeView>
        </Grid>

        <GridSplitter Grid.Column="1" ShowsPreview="True" Width="2"
                      HorizontalAlignment="Center" VerticalAlignment="Stretch">
            <GridSplitter.Background>
                <LinearGradientBrush>
                    <GradientStop Offset="0" Color="{Binding Path=VisualSettings.SecondaryBackgroundColor, FallbackValue=Azure}"/>
                    <GradientStop Offset="1" Color="{Binding Path=VisualSettings.PrimaryBackgroundColor, FallbackValue=Lavender}"/>
                </LinearGradientBrush>
            </GridSplitter.Background>
        </GridSplitter>

        <local:SourceFrame x:Name="sourceFrame" Grid.Column="2" Width="Auto" Height="Auto" />
    </Grid>
</UserControl>
